import styles from './utils.less';
import moment from 'moment';
import cookie from './cookie';
import axios from 'axios';

const global = {
  removeCookie() {
    cookie.remove('team_name', { domain: '' });
    cookie.remove('region_name', { domain: '' });
    cookie.remove('team', { domain: '' });
    cookie.remove('token', { domain: '' });
    cookie.remove('appStore', { domain: '' });
    cookie.remove('newbie_guide', { domain: '' });
    cookie.remove('platform_url', { domain: '' });
  },
  putLog(info) {
    if (!info || info&&!info.enterprise_id) {
      return null;
    }
    try {
      const defaultOptions = {
        credentials: 'same-origin',
      };
      const { title, version } = info;
      defaultOptions.url = 'https://log.rainbond.com/log';
      defaultOptions.method = 'post';
      defaultOptions.data = JSON.stringify({
        url: window.location.href,
        eid: info.enterprise_id,
        e_name: info.enterprise_alias,
        version: version.value,
        title: title.value,
        day:moment(new Date()).locale('zh-cn').format('YYYYMMDD')
      });
      defaultOptions.data=JSON.parse(defaultOptions.data)
      axios(defaultOptions);
    } catch (e) {}
  },
  getCurrEnterpriseId() {
    const reg = /enterprise\/([^\/]+)/;
    const hash = location.hash || '';
    const match = hash.match(reg);
    if (match) {
      return match[1];
    }
    return '';
  },
  getCurrTeamName() {
    const reg = /team\/([^\/]+)/;
    const hash = location.hash || '';
    const match = hash.match(reg);
    if (match) {
      return match[1];
    }
    return '';
  },
  getComponentID() {
    const reg = /components\/([^\/]+)/;
    const hash = location.hash || '';
    const match = hash.match(reg);
    if (match) {
      return match[1];
    }
    return '';
  },
  getAppID() {
    const reg = /apps\/([^\/]+)/;
    const hash = location.hash || '';
    const match = hash.match(reg);
    if (match) {
      return match[1];
    }
    return '';
  },
  getCurrRegionName() {
    const reg = /region\/([^\/]+)/;
    const hash = location.hash || '';
    const match = hash.match(reg);
    if (match) {
      return match[1];
    }
    return '';
  },
  fetchStateColor(status) {
    const statusColorMap = {
      RUNNING: '#00D777', // 运行中 绿色
      running: '#00D777', // 运行中 绿色
      starting: '#F69D4A', // 启动中
      Starting: '#F69D4A', // 启动中
      NOTREADY: '#F69D4A', // 未就绪
      checking: 'F69D4A', // 检测中
      SCHEDULING: '#F69D4A', // 检测中
      stopping: '#20124A', // 关闭中 紫色
      Stopping: '#20124A', // 关闭中 紫色
      unusual: '#CD0200', // 异常 纯红
      ABNORMAL: '#CD0200', // 异常 纯红
      closed: '#000021', // 已关闭 黑色
      Closed: '#000021', // 已关闭 黑色
      undeploy: '#708090', // 未部署 石板灰
      Undeploy: '#708090', // 未部署 石板灰
      Unknow: '#CD0200', // 未知深粉色
      unknow: '#CD0200', // 未知/深粉色
      Creating: '#778899', // 部署中 浅石板灰
      creating: '#778899', // 部署中 浅石板灰
      Third_party: '#5BB2FA',
      Internet: '#5BB2FA', // 蓝色
      TheInternet: '#5BB2FA', // 蓝色
      Abnormal: '#CD0200', // 不正常,纯红
      abnormal: '#CD0200', // 不正常,纯红
      Build_failure: '#CD0200', // 构建失败 纯红
      build_failure: '#CD0200', // 构建失败 纯红
      Upgrade: '#00FF4A', // 升级中
      upgrade: '#00FF4A', // 升级中
      expired: '#CD0200', // 过期 猩红
      Expired: '#CD0200', // 猩红
      UNHEALTHY: '#CD0200',
      INITIATING: '#F69D4A',
      TEMINATING: '#20124A', // 关闭中 紫色
      tEMINATING: '#20124A', // 关闭中 紫色
      Some_abnormal: '#FF0000', // 一些不正常 纯红
      Building: '#007710', // 构建  纯蓝
    };
    return statusColorMap[status] || statusColorMap.unknow;
  },
  confirmEnding(str, target) {
    return str.indexOf(target) > -1 || str.indexOf(target.toLowerCase()) > -1;
  },
  fetchSvg(type, color) {
    const svgType = {
      passwordShow: (
        <svg
          viewBox="64 64 896 896"
          focusable="false"
          data-icon="eye"
          width="1em"
          height="1em"
          fill="currentColor"
          aria-hidden="true"
        >
          <path d="M942.2 486.2C847.4 286.5 704.1 186 512 186c-192.2 0-335.4 100.5-430.2 300.3a60.3 60.3 0 0 0 0 51.5C176.6 737.5 319.9 838 512 838c192.2 0 335.4-100.5 430.2-300.3 7.7-16.2 7.7-35 0-51.5zM512 766c-161.3 0-279.4-81.8-362.7-254C232.6 339.8 350.7 258 512 258c161.3 0 279.4 81.8 362.7 254C791.5 684.2 673.4 766 512 766zm-4-430c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm0 288c-61.9 0-112-50.1-112-112s50.1-112 112-112 112 50.1 112 112-50.1 112-112 112z" />
        </svg>
      ),
      passwordHidden: (
        <svg
          viewBox="64 64 896 896"
          focusable="false"
          data-icon="eye-invisible"
          width="1em"
          height="1em"
          fill="currentColor"
          aria-hidden="true"
        >
          <path d="M942.2 486.2Q889.47 375.11 816.7 305l-50.88 50.88C807.31 395.53 843.45 447.4 874.7 512 791.5 684.2 673.4 766 512 766q-72.67 0-133.87-22.38L323 798.75Q408 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 0 0 0-51.5zm-63.57-320.64L836 122.88a8 8 0 0 0-11.32 0L715.31 232.2Q624.86 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 0 0 0 51.5q56.69 119.4 136.5 191.41L112.48 835a8 8 0 0 0 0 11.31L155.17 889a8 8 0 0 0 11.31 0l712.15-712.12a8 8 0 0 0 0-11.32zM149.3 512C232.6 339.8 350.7 258 512 258c54.54 0 104.13 9.36 149.12 28.39l-70.3 70.3a176 176 0 0 0-238.13 238.13l-83.42 83.42C223.1 637.49 183.3 582.28 149.3 512zm246.7 0a112.11 112.11 0 0 1 146.2-106.69L401.31 546.2A112 112 0 0 1 396 512z" />
          <path d="M508 624c-3.46 0-6.87-.16-10.25-.47l-52.82 52.82a176.09 176.09 0 0 0 227.42-227.42l-52.82 52.82c.31 3.38.47 6.79.47 10.25a111.94 111.94 0 0 1-112 112z" />
        </svg>
      ),
      application: (
        <svg
          width="40px"
          height="40px"
          viewBox="0 0 40 40"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
        >
          <g
            id="应用视图-总览"
            stroke="none"
            strokeWidth="1"
            fill="none"
            fillRule="evenodd"
          >
            <g
              id="应用视图"
              transform="translate(-101.000000, -117.000000)"
              fill="#1296DB"
              fillRule="nonzero"
            >
              <g id="编组" transform="translate(101.000000, 117.000000)">
                <path
                  d="M9.27551722,7.01349432e-05 C4.15848335,7.01349432e-05 0.00372962536,4.15803094 0.00372962536,9.27522519 C0.00372962536,14.3970696 4.15607808,18.5502199 9.27808287,18.5502199 L15.7098533,18.5502199 C17.2789103,18.5502199 18.5471445,17.2734869 18.5471445,15.7045903 L18.5471445,9.27265953 C18.5465031,4.15161683 14.3967203,7.01349432e-05 9.27551722,7.01349432e-05 Z M15.7082498,15.7045903 L15.7082498,15.7057128 C15.7090635,15.7077954 15.709707,15.7099404 15.7101741,15.7121495 L9.27808287,15.7121495 C6.66819785,15.7190058 4.31161857,14.1517228 3.30882288,11.7421693 C2.30602718,9.3326158 2.85485729,6.55617427 4.69901995,4.70939024 C6.5431826,2.86260621 9.31884175,2.3098329 11.7298172,3.30920497 C14.1407927,4.30857703 15.7114215,6.66292771 15.7082498,9.27281987 L15.7082498,15.7045903 Z M15.709212,21.2281198 L9.27808287,21.2281198 C4.15687984,21.2281198 0.00533314098,25.3791854 0.00533314098,30.5003884 C0.00533314098,35.6174223 4.15848335,39.7729778 9.27631898,39.7729778 C14.397522,39.7729778 18.5473048,35.6212708 18.5473048,30.5000677 L18.5473048,24.0682973 C18.5465031,22.49908 17.2781085,21.2281198 15.709212,21.2281198 Z M15.7082498,30.4999074 C15.7109758,33.0857609 14.1631833,35.4212282 11.7805563,36.4260839 C10.9892128,36.7607413 10.1471977,36.9267069 9.27808287,36.9267069 C8.40960946,36.9267069 7.56823575,36.7607413 6.77657156,36.4257632 C3.95286702,35.2383149 2.35859126,32.2240658 2.96625896,29.2217199 C3.57392665,26.219374 6.21486164,24.0623215 9.27808287,24.0662605 L15.7109758,24.0662605 C15.7103432,24.0662605 15.7096842,24.0662605 15.7090516,24.0662605 L15.7090516,30.499266 L15.7082498,30.4999074 Z M30.5442966,21.2281197 L24.1125261,21.2281197 C23.3592546,21.2281197 22.6367863,21.5271102 22.1041428,22.0597536 C21.5714994,22.592397 21.2725089,23.3148654 21.2725089,24.0681369 L21.2725089,30.4999074 C21.2725089,35.6211104 25.4235746,39.7726571 30.5447777,39.7726571 C35.6618115,39.7726571 39.817367,35.6174223 39.817367,30.5003884 C39.817367,25.3791854 35.6654996,21.2281197 30.5442966,21.2281197 L30.5442966,21.2281197 Z M36.4740009,33.001098 C35.2861041,35.825365 32.2712244,37.4199679 29.2681632,36.8123446 C26.265102,36.2047214 24.1072761,33.5635009 24.110758,30.4995867 L24.110758,24.066373 L30.5436552,24.066373 C32.6998426,24.0667719 34.7125897,25.1468281 35.9049864,26.9433063 C37.0973832,28.7397846 37.3110022,31.0139963 36.4740009,33.001098 L36.4740009,33.001098 Z M24.1125261,18.5502199 L30.5442966,18.5502199 C35.6654996,18.5502199 39.8170463,14.3970696 39.8170463,9.27506481 C39.8170463,4.15803094 35.6618115,0.00119264915 30.5447777,0.00119264915 C25.4235746,0.00119264915 21.272509,4.1514565 21.272509,9.27265953 L21.272509,15.70443 C21.272509,17.2734869 22.5434692,18.5502199 24.1125261,18.5502199 L24.1125261,18.5502199 Z M24.1107623,9.27265953 C24.1135957,5.71974823 26.9956581,2.84160943 30.54857,2.84361507 C34.1014819,2.8456228 36.9802913,5.72701533 36.9791118,9.27992757 C36.9779315,12.8328398 34.097209,15.7123197 30.5442966,15.7119666 L24.1107623,15.7119666 C24.1105385,15.709839 24.1105385,15.7076801 24.1107623,15.7055525 L24.1107623,9.27265953 L24.1107623,9.27265953 Z"
                  id="形状"
                />
              </g>
            </g>
          </g>
        </svg>
      ),
      component: (
        <svg
          t="1582714685365"
          className="icon"
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="2601"
          width="40"
          height="40"
        >
          <path
            d="M64 64h384v384H64V64z m0 512h384v384H64V576z m512 0h384v384H576V576z m192-128c106.039 0 192-85.961 192-192S874.039 64 768 64s-192 85.961-192 192 85.961 192 192 192z"
            p-id="2602"
            fill="#1296db"
          />
        </svg>
      ),
      logs: (
        <svg
          style={{
            cursor: 'pointer',
          }}
          t="1566527207023"
          className={styles.iconm}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="5957"
          width="16"
          height="16"
        >
          <path
            d="M902.8 892l-95.5-96.3c62.4-95.5 35.6-223.5-59.9-285.9s-223.5-35.6-285.9 59.9-35.6 223.5 59.9 285.9c33.7 22 73.1 33.7 113.4 33.6 40.6-0.1 80.3-12.2 114-34.8l95.6 96.2c11.9 11.9 31.3 11.9 43.2 0l15.3-15.4c11.9-12.1 11.9-31.4 0-43.5l-0.1 0.3zM746.4 734.6C732 765 706 788.3 674.2 799.3c-12.7 5-26.2 7.4-39.8 6.9-69.6 1-126.7-54.6-127.7-124.2S561.4 555.3 631 554.3 757.7 609 758.6 678.5c0.3 19.5-4 38.7-12.4 56.2l0.2-0.1zM364.6 720H263.4c-17.5-0.7-31.2-15.5-30.5-33 0.7-16.6 13.9-29.8 30.5-30.5H363c2.5-29.2 9.8-57.8 21.4-84.6H263.5c-17.5-0.7-31.2-15.5-30.5-33 0.7-16.6 13.9-29.8 30.5-30.5h159.3c31.1-38.5 72.1-67.8 118.6-84.6H263.5c-17.5 0-31.8-14.2-31.7-31.8 0-17.5 14.2-31.7 31.7-31.7H749c17.5 0 31.8 14.2 31.7 31.8 0 17.5-14.2 31.7-31.7 31.7h-23.8c85.9 31.3 150.5 103.6 171.9 192.6V160.1c0.1-52.9-42.7-96-95.6-96.3H210.8c-52.9 0.4-95.5 43.3-95.5 96.2v687c0 52.9 42.7 95.9 95.6 96.2h346.4C455 912.9 379.7 825.7 364.6 720zM263.4 212.2H749c17.5 0.7 31.2 15.5 30.5 33-0.7 16.6-13.9 29.8-30.5 30.5H263.4c-17.5-0.7-31.2-15.5-30.5-33 0.7-16.6 14-29.8 30.5-30.5z"
            fill={color || '#000'}
            p-id="5958"
          />
        </svg>
      ),
      runTime: (
        <svg
          t="1567065687158"
          className={styles.iconm}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="19354"
          width="12"
          height="12"
        >
          <path
            d="M874.057143 150.016A508.635429 508.635429 0 0 0 512.073143 0.146286c-136.704 0-265.216 53.248-361.837714 149.942857A508.489143 508.489143 0 0 0 0.292571 512c0 136.777143 53.174857 265.289143 149.869715 362.057143A508.635429 508.635429 0 0 0 512 1023.780571c136.777143 0 265.362286-53.321143 362.057143-149.942857 199.533714-199.533714 199.606857-524.288 0-723.894857z m-49.444572 674.377143A439.296 439.296 0 0 1 512 954.075429a439.149714 439.149714 0 0 1-312.466286-129.462858A439.076571 439.076571 0 0 1 70.217143 512c0-118.052571 45.933714-229.083429 129.462857-312.539429A439.003429 439.003429 0 0 1 512 70.070857c118.125714 0 229.083429 45.933714 312.539429 129.462857a442.514286 442.514286 0 0 1 0 624.932572zM544.036571 535.186286V256.073143c0-23.552-11.410286-46.226286-34.962285-46.226286-23.552 0-38.034286 22.674286-38.034286 46.226286v298.569143c0 24.356571 30.281143 35.401143 51.638857 50.029714 14.262857 9.728 67.291429 41.837714 159.158857 96.329143 20.772571 10.825143 52.077714 25.088 65.682286 2.925714 13.531429-22.016-9.654857-45.933714-32.694857-60.708571-15.36-9.874286-72.265143-45.933714-170.788572-108.105143z"
            fill="#000000"
            p-id="19355"
          />
        </svg>
      ),
      distributionMemory: (
        <svg
          t="1565779336591"
          className={styles.icon}
          viewBox="0 0 1099 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="1890"
          width="16"
          height="16"
        >
          <path
            d="M841.66 313.7 676.06 189.2c-3.7-2.8-8.1-4.3-12.7-4.3L277.56 185c-8.5 0-16.7 5.9-16.7 16.8l0 618.8c0 13.9 12 27.2 27.3 27.2l552.2 0c8.8 0 14.8-4.3 14.8-14.2L855.16 330.1C855.06 323.4 847.06 317.7 841.66 313.7zM682.36 257.7l0 124.5c0 4.9-2.4 9.2-7.8 9.2l-262 0c-7.2 0-8.2-3.8-8.2-9.5l0-145.1 248.4 0L682.36 257.7zM804.66 778.6c0 10.7-6.5 18-16.9 18l-461 0c-8.1 0.1-13.5-5.8-13.5-14.5L313.26 248.4c0-7.1 6.6-11.5 15.3-11.5 7.5 0 17 0 27.7 0l0.1 190.4c0 6.9 4.3 10.1 10.8 10.1l346.1-0.1c6.8 0.1 10.7-5 10.5-12.7l0.1-135.2 80.8 60.4L804.66 778.6zM371.56 621.2l188.7 0c6.7 0 11.2-4.3 11.2-10.4 0-5.2 0-20.1 0-25.7 0-6.6-7-10.8-13.2-10.8L370.16 574.3c-7.8 0-11.7 4.9-11.7 10.8 0 6.4 0 21.7 0 25.4C358.46 616.5 363.16 621.2 371.56 621.2zM709.86 574.3l-95 0c-8.2 0-14.1 4.7-14.1 11.3 0 4.7 0 19 0 23.8 0 8.1 6.3 11.9 13.6 11.9l94.3 0c8.4 0 15.2-5.9 15.2-13.2 0-6.2 0-11.8 0-18.9C723.96 581.2 718.46 574.3 709.86 574.3zM480.06 698.5 371.76 698.5c-8.3 0-13.4 4.3-13.4 13.3 0 6 0 12.2 0 17.3 0 8.9 5.4 14.4 13.7 14.4l105.6 0c7.9 0 15.1-5.3 15.1-14 0-6.7 0-11.6 0-16.3C492.76 705 486.06 698.5 480.06 698.5zM709.06 698.5 533.56 698.5c-8.9 0-14.2 6.5-14.2 14.1 0 4.4 0 12.5 0 17.3 0 6.2 5.6 13.6 14.5 13.6l174 0c8.9 0 16-6.3 16-15.4 0-4.1 0-8.7 0-14.9C723.96 704.8 718.66 698.5 709.06 698.5zM627.46 360.4c7.3 0 13.2-6.1 13.2-11.4L640.66 277.4c0-7.4-4.1-11.5-10.3-11.5-5.1 0-24.9 0-29.3 0-6.2 0-9.2 4.5-9.2 11.4l0 71.9c0 6.4 6.3 11.3 11.9 11.3C608.56 360.4 622.06 360.4 627.46 360.4z"
            p-id="1891"
          />
        </svg>
      ),
      useDisk: (
        <svg
          style={{ marginRight: '6px' }}
          t="1566640777774"
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="20451"
          width="15"
          height="14"
        >
          <path
            d="M615.7 82H67v860h890V368.4L615.7 82z m-317.1 50h298.9l2.1 1.7v214.9h-301V132zM724 892H298.6V642.6H724V892z m183 0H774V592.6H248.6V892H117V132h131.6v266.6h401v-223l257.5 216V892zM353.1 192.1h50v80h-50v-80z"
            p-id="20452"
          />
        </svg>
      ),
      version: (
        <svg
          t="1565853114924"
          className={styles.icon}
          viewBox="0 0 1184 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="6049"
          width="16"
          height="16"
        >
          <path
            d="M448.576 576l118.272 0q-8 90.272-56.288 142.016t-122.56 51.712q-92.576 0-145.44-66.272t-52.864-180.576q0-110.848 53.152-178.016t133.152-67.136q84.576 0 132.576 49.728t55.424 141.152l-116 0q-2.848-36.576-20.288-56.576t-46.56-20q-32.576 0-50.56 34.56t-18.016 101.44q0 27.424 2.848 48t10.272 39.712 22.848 29.44 37.728 10.272q54.272 0 62.272-79.424zM855.424 576l117.728 0q-8 90.272-56 142.016t-122.272 51.712q-92.576 0-145.44-66.272t-52.864-180.576q0-110.848 53.152-178.016t133.152-67.136q84.576 0 132.576 49.728t55.424 141.152l-116.576 0q-2.272-36.576-20-56.576t-46.272-20q-32.576 0-50.56 34.56t-18.016 101.44q0 27.424 2.848 48t10.272 39.712 22.56 29.44 37.44 10.272q28 0 43.712-21.728t19.136-57.728zM1060.576 508q0-118.272-8.864-175.424t-34.56-92q-3.424-4.576-7.712-8t-12.288-8.576-9.152-6.272q-49.152-36-398.272-36-357.152 0-405.728 36-2.848 2.272-10.016 6.56t-12 8-8.288 8.288q-25.728 34.272-34.272 91.136t-8.576 176.288q0 118.848 8.576 175.712t34.272 91.712q3.424 4.576 8.576 8.576t11.712 8 10.016 6.848q25.152 18.848 136.864 28t268.864 9.152q348.576 0 398.272-37.152 2.848-2.272 9.728-6.272t11.712-8 7.712-9.152q26.272-34.272 34.848-90.848t8.576-176.576zM1170.272 73.152l0 877.728-1170.272 0 0-877.728 1170.272 0z"
            p-id="6050"
          />
        </svg>
      ),
      warehouse: (
        <svg
          t="1567065405232"
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="11295"
          width="16"
          height="16"
        >
          <path
            d="M960 448h-267.168a191.744 191.744 0 0 0-361.6 0H64v128h267.168a191.744 191.744 0 0 0 361.6 0H960z m-448 192a128 128 0 1 1 128-128 128 128 0 0 1-128 128z"
            fill="#000000"
            p-id="11296"
          />
        </svg>
      ),

      basicInfo: (
        <svg
          t="1567065519867"
          className={styles.iconm}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="18494"
          width="12"
          height="12"
        >
          <path
            d="M980.76306 840.106926c0 101.570274-82.384097 183.893074-183.893073 183.893074s-183.893074-82.322799-183.893074-183.893074c0-79.993487 51.367465-147.298352 122.595382-172.614298V349.725396c0-33.897623-27.400068-61.297691-61.297691-61.297691v61.236393a61.338556 61.338556 0 0 1-104.635159 43.398766l-122.595382-122.656681A61.032068 61.032068 0 0 1 429.083839 227.068716c0-15.630911 6.007174-31.32312 17.960224-43.27617l122.595382-122.595383A61.256826 61.256826 0 1 1 674.274604 104.473333V165.832322c101.508977 0 183.893074 82.322799 183.893074 183.893074v317.767232c71.227917 25.315946 122.595383 92.620812 122.595382 172.614298z m-183.893073-61.297691c-33.897623 0-61.297691 27.400068-61.297692 61.297691s27.400068 61.297691 61.297692 61.297691 61.297691-27.400068 61.297691-61.297691-27.400068-61.297691-61.297691-61.297691z m-429.083839 61.297691c0 101.570274-82.322799 183.893074-183.893074 183.893074s-183.893074-82.322799-183.893074-183.893074c0-79.993487 51.306168-147.298352 122.595383-172.614298V399.744312C51.306168 374.428366 0 307.1235 0 227.130013c0-101.570274 82.322799-183.893074 183.893074-183.893073s183.893074 82.322799 183.893074 183.893073c0 79.993487-51.306168 147.298352-122.595383 172.614299v267.687018c71.289215 25.377244 122.595383 92.682109 122.595383 172.675596zM183.893074 165.832322a61.297691 61.297691 0 1 0 0 122.595383 61.297691 61.297691 0 1 0 0-122.595383z m0 612.976913a61.297691 61.297691 0 1 0 0 122.595382 61.297691 61.297691 0 1 0 0-122.595382z"
            p-id="18495"
            fill="#000000"
          />
        </svg>
      ),
      branch: (
        <svg
          t="1567065220584"
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="2245"
          width="16"
          height="16"
        >
          <path
            d="M863 192.050c0-63-51.3-114.3-114.3-114.3s-114.3 51.3-114.3 114.3c0 54.9 39.15 100.8 90.9 111.6-7.65 118.35-88.2 190.8-213.3 190.8-90.45 0-153 44.1-190.35 82.35v-272.7c52.2-10.8 91.35-56.7 91.35-112.050 0-63-51.3-114.3-114.3-114.3s-113.85 51.3-113.85 114.3c0 55.35 39.6 101.25 91.8 112.050v416.25c-52.2 10.35-91.8 56.7-91.8 112.050 0 63 51.3 114.3 114.3 114.3s113.85-51.75 113.85-114.75c0-55.35-39.6-101.25-91.8-112.050v-71.55c13.5-21.6 75.15-108.9 190.35-108.9 76.95 0 141.75-24.3 188.55-70.2 42.3-41.85 66.15-98.55 70.2-165.15 53.1-10.35 92.7-56.7 92.7-112.050zM229.85 192.050c0-38.25 31.050-69.3 69.3-69.3s69.3 31.050 69.3 69.3-31.050 69.3-69.3 69.3-69.3-31.050-69.3-69.3zM368 831.95c0 38.25-31.050 69.3-69.3 69.3s-69.3-31.050-69.3-69.3 31.050-69.3 69.3-69.3 69.3 31.050 69.3 69.3zM748.7 261.35c-38.25 0-69.3-31.050-69.3-69.3s31.050-69.3 69.3-69.3 69.3 31.050 69.3 69.3-31.050 69.3-69.3 69.3z"
            fill="#000000"
            p-id="2246"
          />
        </svg>
      ),
      logState: (
        <svg
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="26201"
          width="16"
          height="16"
        >
          <path
            d="M951.509333 507.2L465.194667 993.514667c-0.682667 1.024-1.130667 2.176-2.026667 3.072a20.8 20.8 0 0 1-15.253333 5.994666 20.8 20.8 0 0 1-15.253334-5.994666c-0.896-0.896-1.322667-2.048-2.026666-3.072L73.066667 635.946667c-1.024-0.682667-2.154667-1.130667-3.072-2.026667A20.8 20.8 0 0 1 64 618.666667a20.693333 20.693333 0 0 1 5.994667-15.253334c0.917333-0.896 2.048-1.322667 3.072-2.026666L559.381333 115.093333A20.906667 20.906667 0 0 1 575.914667 106.666667h86.528c2.837333-32.042667 15.914667-60.16 35.626666-78.570667l0.341334 0.384c4.181333-4.416 9.877333-7.146667 16.170666-7.146667 12.629333 0 22.869333 10.922667 22.869334 24.384 0 8-3.84 14.741333-9.408 19.178667-10.218667 9.429333-17.493333 24.298667-19.925334 41.770667h102.464c6.826667 0 12.672 3.413333 16.533334 8.426666l124.373333 124.373334a20.992 20.992 0 0 1 8.426667 16.554666V490.666667a20.906667 20.906667 0 0 1-8.405334 16.533333z m-220.757333-151.658667a22.101333 22.101333 0 0 1-16.170667 7.125334c-12.629333 0-22.826667-10.922667-22.826666-24.384 0-8 3.84-14.741333 9.408-19.2 5.290667-4.885333 9.621333-11.456 13.162666-18.837334-18.24 4.864-31.744 21.333333-31.744 41.066667a42.666667 42.666667 0 0 0 85.333334 0c0-10.090667-3.626667-19.221333-9.493334-26.538667-13.12 33.002667-27.669333 40.768-27.669333 40.768z m186.496-91.413333L802.453333 149.333333h-89.877333c3.712 9.472 9.045333 17.536 15.466667 23.466667 0.874667 0.704 1.962667 1.130667 2.709333 1.962667l0.384-0.384c22.208 20.757333 36.8 53.504 36.8 90.752 0 0.896-0.213333 1.685333-0.256 2.56 25.536 14.741333 42.922667 42.026667 42.922667 73.642666a85.333333 85.333333 0 0 1-170.666667 0 85.141333 85.141333 0 0 1 81.493333-84.949333c-1.92-18.944-9.408-35.157333-20.245333-45.184-0.874667-0.704-1.962667-1.130667-2.752-1.962667l-0.341333 0.384C682.218667 194.794667 670.506667 173.674667 664.96 149.333333h-80.917333l-469.333334 469.333334 333.205334 333.205333 469.333333-469.333333V264.128zM304.682667 582.08a20.842667 20.842667 0 0 1 29.461333 0l150.378667 150.378667a20.842667 20.842667 0 0 1-29.461334 29.461333l-150.378666-150.378667a20.842667 20.842667 0 0 1 0-29.461333z m85.333333-85.333333a20.842667 20.842667 0 0 1 29.461333 0l150.357334 150.378666a20.842667 20.842667 0 0 1-29.461334 29.461334l-150.357333-150.378667a20.842667 20.842667 0 0 1 0-29.461333z"
            fill={color || '#000'}
            p-id="26202"
          />
        </svg>
      ),
      createTime: (
        <svg
          t="1567066044003"
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="4001"
          width="16"
          height="16"
        >
          <path
            d="M720.32 257.344l-403.648-0.576a21.632 21.632 0 1 1 0-43.2l403.648 0.512a21.632 21.632 0 0 1 0 43.264z"
            p-id="4002"
            fill="#000000"
          />
          <path
            d="M882.88 921.344H143.808c-33.6 0-57.152-19.584-57.152-47.68V261.76c0-27.968 24-48.192 57.152-48.192H212.48a21.632 21.632 0 1 1 0 43.264H143.808c-6.528 0-13.824 2.112-13.824 4.992v611.968c0.64 1.728 5.248 4.416 13.824 4.416h739.072a11.136 11.136 0 0 0 11.136-11.136v-599.04a11.136 11.136 0 0 0-11.136-11.136h-71.488a21.632 21.632 0 0 1 0-43.264h71.488a54.4 54.4 0 0 1 54.4 54.4v599.04a54.4 54.4 0 0 1-54.4 54.272z"
            p-id="4003"
            fill="#000000"
          />
          <path
            d="M915.648 413.568H114.816a21.632 21.632 0 1 1 0-43.264h800.768a21.632 21.632 0 0 1 0.064 43.264zM264.576 309.44a21.632 21.632 0 0 1-21.632-21.632V170.624a21.632 21.632 0 1 1 43.264 0v117.184a21.632 21.632 0 0 1-21.632 21.632zM772.352 309.44a21.568 21.568 0 0 1-21.632-21.632V170.624c0-11.968 9.6-21.632 21.632-21.632s21.632 9.664 21.632 21.632v117.184c0 11.968-9.6 21.632-21.632 21.632zM416.512 504.384c51.712 0 82.624 30.08 82.624 75.264 0 92.608-143.232 119.616-143.232 165.888h134.72a12.032 12.032 0 0 1 0 24.064H341.632a12.096 12.096 0 0 1-11.968-12.032c0-84.928 143.616-94.144 143.616-177.856 0-29.824-20.096-52.16-56.768-52.16-32 0-45.952 16.256-54.784 35.52-2.368 4.992-6.144 7.744-11.2 7.744a12.032 12.032 0 0 1-11.2-16.256c10.432-31.296 37.44-50.176 77.184-50.176zM539.648 690.816c0-33.28 16.96-57.856 45.504-68.672-17.28-9.28-33.984-25.472-33.984-56 0-46.272 32.064-67.072 78.72-67.072 46.72 0 78.72 20.8 78.72 67.072 0 30.592-16.576 46.72-33.984 56 28.608 10.816 45.632 35.456 45.632 68.672 0 52.48-36.672 78.72-90.368 78.72-53.568 0-90.24-26.24-90.24-78.72z m25.472 0c0 38.656 26.624 55.616 64.832 55.616s64.96-17.024 64.96-55.616c0-38.272-24.448-55.936-64.96-55.936s-64.832 17.664-64.832 55.936z m11.648-124.672c0 30.592 20.8 45.568 53.184 45.568 32.448 0 53.312-14.976 53.312-45.568 0-29.696-20.032-43.968-53.312-43.968-33.216 0-53.184 14.272-53.184 43.968z"
            p-id="4004"
            fill="#000000"
          />
        </svg>
      ),
      currentVersion: (
        <svg
          style={{
            cursor: 'pointer',
          }}
          t="1566532978509"
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="10598"
          width="16"
          height="16"
        >
          <path
            d="M512 42.666667C251.733333 42.666667 42.666667 251.733333 42.666667 512s209.066667 469.333333 469.333333 469.333333 469.333333-209.066667 469.333333-469.333333S772.266667 42.666667 512 42.666667z m0 874.666666C288 917.333333 106.666667 736 106.666667 512S288 106.666667 512 106.666667s405.333333 181.333333 405.333333 405.333333-181.333333 405.333333-405.333333 405.333333z"
            p-id="10599"
            fill="#1296db"
          />
          <path
            d="M544 279.466667c-10.666667 10.666667-14.933333 23.466667-14.933333 40.533333 0 12.8 4.266667 23.466667 12.8 32 8.533333 8.533333 19.2 12.8 32 12.8 10.666667 0 23.466667-2.133333 38.4-17.066667 10.666667-10.666667 14.933333-25.6 14.933333-40.533333 0-12.8-4.266667-23.466667-12.8-32-19.2-19.2-51.2-17.066667-70.4 4.266667zM556.8 644.266667c-14.933333 14.933333-25.6 23.466667-34.133333 29.866666 4.266667-19.2 12.8-57.6 34.133333-130.133333 21.333333-72.533333 23.466667-87.466667 23.466667-91.733333 0-10.666667-4.266667-21.333333-12.8-27.733334-17.066667-14.933333-49.066667-12.8-87.466667 10.666667-21.333333 12.8-44.8 32-68.266667 59.733333l-12.8 14.933334 44.8 34.133333 10.666667-10.666667c12.8-12.8 21.333333-19.2 25.6-25.6-34.133333 110.933333-49.066667 179.2-49.066667 209.066667 0 14.933333 4.266667 25.6 12.8 34.133333 8.533333 8.533333 19.2 12.8 32 12.8s27.733333-4.266667 44.8-14.933333c17.066667-8.533333 40.533333-29.866667 74.666667-61.866667l12.8-12.8-40.533333-38.4-10.666667 8.533334z"
            p-id="10600"
            fill="#1296db"
          />
        </svg>
      ),
      upgrade: (
        <svg
          style={{
            cursor: 'pointer',
          }}
          t="1566533552365"
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="11396"
          width="16"
          height="16"
        >
          <path
            d="M512 57.6c249.6 0 454.4 204.8 454.4 454.4s-204.8 454.4-454.4 454.4S57.6 761.6 57.6 512 262.4 57.6 512 57.6M512 0C230.4 0 0 230.4 0 512s230.4 512 512 512 512-230.4 512-512-230.4-512-512-512z"
            p-id="11397"
            fill="#000000"
          />
          <path
            d="M326.4 492.8l160-160v428.8c0 19.2 12.8 32 32 32s32-12.8 32-32V332.8l160 160c12.8 12.8 32 12.8 44.8 0s12.8-32 0-44.8L531.2 243.2s-6.4-6.4-12.8-6.4h-25.6c-6.4 0-6.4 6.4-12.8 6.4L281.6 448c-12.8 12.8-12.8 32 0 44.8s32 12.8 44.8 0z"
            p-id="11398"
            fill="#000000"
          />
        </svg>
      ),
      rollback: (
        <svg
          style={{
            cursor: 'pointer',
          }}
          t="1566533701108"
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="14118"
          width="16"
          height="16"
        >
          <path
            d="M416 640V384H512v185.6l115.2 32-25.6 89.6-185.6-51.2zM512 102.4c243.2 0 448 198.4 448 448s-198.4 448-448 448-448-198.4-448-448c0-89.6 19.2-172.8 76.8-243.2l64 44.8c-38.4 57.6-57.6 128-57.6 198.4 0 198.4 166.4 364.8 364.8 364.8s364.8-166.4 364.8-364.8S710.4 185.6 512 185.6v102.4L326.4 147.2 512 0v102.4z"
            p-id="14119"
            fill="#000000"
          />
        </svg>
      ),
      delete: (
        <svg
          style={{
            cursor: 'pointer',
          }}
          t="1566533607654"
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="11648"
          width="16"
          height="16"
        >
          <path
            d="M950.857143 219.428571h-182.857143V73.142857h-512v146.285714H73.142857v73.142858h109.714286v658.285714h658.285714V292.571429H950.857143V219.428571zM329.142857 146.285714h365.714286v73.142857h-365.714286V146.285714z m438.857143 731.428572h-512V292.571429h146.285714v438.857142h73.142857V292.571429h73.142858v438.857142h73.142857V292.571429h146.285714v585.142857z"
            p-id="11649"
            fill="#000000"
          />
        </svg>
      ),
      success: (
        <svg
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="31270"
          width="16"
          height="16"
        >
          <path
            d="M927.97968 108.360629a50.575037 50.575037 0 0 0-69.085501 18.517689l-391.898737 678.933747-316.000056-182.409708A50.575037 50.575037 0 0 0 100.427574 711.005546l359.812488 207.690002a50.553362 50.553362 0 0 0 69.078276-18.517689L946.504593 177.44613a50.575037 50.575037 0 0 0-18.524913-69.085501z"
            fill="#46AF60"
            p-id="31271"
          />
        </svg>
      ),
      error: (
        <svg
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="32079"
          width="16"
          height="16"
        >
          <path
            d="M 909.812 962.028 c -13.094 0 -26.188 -4.996 -36.179 -14.987 L 73.958 147.368 c -19.98 -19.98 -19.98 -52.378 0 -72.359 c 19.983 -19.98 52.38 -19.98 72.36 0 L 945.99 874.683 c 19.981 19.981 19.981 52.378 0 72.36 c -9.99 9.99 -23.084 14.985 -36.179 14.985 Z"
            fill="#db4545"
            p-id="32080"
          />
          <path
            d="M 110.138 962.028 c -13.094 0 -26.188 -4.996 -36.179 -14.987 c -19.98 -19.98 -19.98 -52.378 0 -72.359 L 873.632 75.01 c 19.982 -19.98 52.377 -19.98 72.36 0 c 19.98 19.981 19.98 52.378 0 72.36 L 146.316 947.041 c -9.99 9.99 -23.084 14.986 -36.179 14.986 Z"
            fill="#db4545"
            p-id="32081"
          />
        </svg>
      ),
      close: (
        <svg
          className={styles.icon}
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="43063"
          width="16"
          height="16"
        >
          <path
            d="M511.998049 66.069397c-246.273427 0-445.926662 199.653235-445.926662 445.926462s199.653035 445.931458 445.926662 445.931458c246.296411 0 445.926462-199.658032 445.926462-445.931458S758.29446 66.069397 511.998049 66.069397zM511.998049 920.100164c-225.395582 0-408.104305-182.709523-408.104305-408.104305 0-225.395582 182.708723-408.105305 408.104305-408.105305 225.41357 0 408.125291 182.709723 408.125291 408.105305C920.12334 737.410428 737.411619 920.100164 511.998049 920.100164zM816.163025 803.452451 233.172693 196.400632l-25.336822 23.633976 583.593923 607.556477L816.163025 803.452451z"
            p-id="43064"
            fill="#9d9d9d"
          />
        </svg>
      ),
    };
    return svgType[type] || type;
  },

  fetchStateBJColor(status) {
    const statusColorMap = {
      running:
        'linear-gradient(to right, #00D777 0, #00D777 10px, #fff 10px, #fff 100%) no-repeat', // 运行中 绿色
      starting:
        'linear-gradient(to right, #F69D4A 0, #F69D4A 10px, #fff 10px, #fff 100%) no-repeat', // 启动中
      checking:
        'linear-gradient(to right, #F69D4A 0, #F69D4A 10px, #fff 10px, #fff 100%) no-repeat', // 检测中
      stopping:
        'linear-gradient(to right, #20124A 0, #20124A 10px, #fff 10px, #fff 100%) no-repeat', // 关闭中 紫色
      unusual:
        'linear-gradient(to right, #CD0200 0, #CD0200 10px, #fff 10px, #fff 100%) no-repeat', // 异常
      closed:
        'linear-gradient(to right, #000021 0, #000021 10px, #fff 10px, #fff 100%) no-repeat', // 已关闭
      undeploy:
        'linear-gradient(to right, #708090 0, #708090 10px, #fff 10px, #fff 100%) no-repeat', // 未部署 石板灰
      unKnow:
        'linear-gradient(to right, #CD0200 0, #CD0200 10px, #fff 10px, #fff 100%) no-repeat', // 未知
      upgrade:
        'linear-gradient(to right, #00FF4A 0, #00FF4A 10px, #fff 10px, #fff 100%) no-repeat', // 升级中
      creating:
        'linear-gradient(to right, #778899 0, #778899 10px, #fff 10px, #fff 100%) no-repeat', // 部署中
      expired:
        'linear-gradient(to right, #CD0200 0, #CD0200 10px, #fff 10px, #fff 100%) no-repeat', // 过期
    };
    return statusColorMap[status] || statusColorMap.unKnow;
  },

  fetchStateText(state) {
    const statusColorMap = {
      RUNNING: '运行中',
      running: '运行中',
      starting: '启动中',
      checking: '检测中',
      stopping: '关闭中',
      unusual: '运行异常',
      closed: '已关闭',
      undeploy: '未部署',
      unKnow: '未知',
      UNKNOWN: '未知',
      ABNORMAL: '运行异常',
      TEMINATING: '关闭中',
      INITIATING: '等待启动',
      SCHEDULING: '调度中',
      TheInternet: '未知',
      upgrade: '升级中',
      creating: '部署中',
      expired: '过期',
      NOTREADY: '未就绪',
      UNHEALTHY: '不健康',
    };
    return statusColorMap[state] || statusColorMap.TheInternet;
  },
  fetchTime(value) {
    const second = value; // 时间差的毫秒数
    let result = '';

    // 计算出相差天数
    const days = Math.floor(second / (24 * 3600 * 1000));

    // 计算出小时数

    const leave1 = second % (24 * 3600 * 1000); // 计算天数后剩余的毫秒数
    const hours = Math.floor(leave1 / (3600 * 1000));
    // 计算相差分钟数
    const leave2 = leave1 % (3600 * 1000); // 计算小时数后剩余的毫秒数
    const minutes = Math.floor(leave2 / (60 * 1000));

    // 计算相差秒数
    const leave3 = leave2 % (60 * 1000); // 计算分钟数后剩余的毫秒数
    const seconds = Math.round(leave3 / 1000);

    if (days && days >= 1) {
      result += `${days}天`;
    }
    if (hours && hours >= 1) {
      result += `${hours}小时`;
    }

    if (minutes && minutes >= 1) {
      result += `${minutes}分钟`;
    }

    if (seconds && seconds >= 1) {
      result += `${seconds}秒`;
    }
    return result || '1秒';
  },
  fetchdayTime(date) {
    const second = Date.parse(new Date()) - new Date(date).getTime();
    // 计算出相差天数
    const days = Math.floor(second / (24 * 3600 * 1000));
    // 计算出小时数

    const leave1 = second % (24 * 3600 * 1000); // 计算天数后剩余的毫秒数
    const hours = Math.floor(leave1 / (3600 * 1000));
    // 计算相差分钟数
    const leave2 = leave1 % (3600 * 1000); // 计算小时数后剩余的毫秒数
    const minutes = Math.floor(leave2 / (60 * 1000));

    // 计算相差秒数
    const leave3 = leave2 % (60 * 1000); // 计算分钟数后剩余的毫秒数
    const seconds = Math.round(leave3 / 1000);

    let result = '';
    if (days && days > 7) {
      result = moment(date)
        .locale('zh-cn')
        .format('YYYY-MM-DD');
    } else if (days && days >= 1 && days < 7) {
      result += `${days}天前`;
    } else if (hours && hours >= 1 && hours <= 23) {
      result += `${hours}小时前`;
    } else if (minutes && minutes >= 1 && minutes <= 59) {
      result += `${minutes}分钟前`;
    } else if (seconds && seconds >= 1 && seconds <= 59) {
      result += `${seconds}秒前`;
    } else {
      result = '1秒前';
    }
    return result;
  },
  fetchInstanceReasons(type) {
    const reasonsType = {
      UnknownContainerStatuses: '未知的容器状态',
      ContainersNotReady: '容器未就绪',
      ContainersNotInitialized: '容器尚未初始化',
    };
    return reasonsType[type] || type;
  },
  fetchInstanceAdvice(type) {
    const adviceType = {
      OutOfMemory:
        '内存不足, 建议为程序分配更多内存, 或检查程序是否合理使用内存',
      Unhealthy:
        '健康检测不通过, 请检查程序的端口是否可用, 以及健康检测配置是否正确',
      Initiating: '等待启动中, 请检查该组件所依赖的组件是否已经正常启动',
    };
    return adviceType[type] || type;
  },
  fetchOperation(finalstatus, status) {
    if (finalstatus == '') {
      return (
        <span style={{ color: '#F69C49', paddingLeft: '5px' }}>进行中</span>
      );
    }
    if (
      finalstatus == 'timeout' ||
      (finalstatus == 'complete' && status == 'timeout')
    ) {
      return <span style={{ color: 'rgba(0, 0, 0, 0.65)' }}>操作已超时</span>;
    }

    if (finalstatus == 'empty' || finalstatus == 'emptycomplete') {
      return <span />;
    }
    switch (status) {
      case 'success':
        return <span style={{ color: '#39AA56' }}>成功</span>;
      case 'failure':
        return <span style={{ color: '#F5212D' }}>失败</span>;
    }
  },
  fetchAbnormalcolor(type) {
    const abnormalcolor = {
      AbnormalRecovery: '#39AA56',
      OOMKilled: '#CD0200',
      LivenessProbeFailed: '#CD0200',
      ReadinessProbeFailed: '#CD0200',
      AbnormalShtdown: '#CD0200',
      EventTypeAbnormalExited: '#CD0200',
      AbnormalExited: '#CD0200',
    };
    return abnormalcolor[type] || 'rgba(0,0,0,0.65)';
  },
  fetchStateOptTypeText(state) {
    const statusOptType = {
      deploy: '构建组件',
      delete: '删除组件',
      HorizontalUpgrade: '水平升级',
      VerticalUpgrade: '垂直升级',
      create: '创建组件',
      callback: '回滚',
      'git-change': '代码仓库修改',
      own_money: '欠费关闭',
      add_label: '添加标签',
      delete_label: '删除标签',
      service_state: '应用状态修改',
      reboot: '重启组件',
      market_sync: '云市同步',
      truncate: '删除组件',
      EventTypeAbnormalExited: '组件异常退出',
      OOMKilled: '发生OOM',
      LivenessProbeFailed: '健康检查不通过(重启)',
      ReadinessProbeFailed: '健康检查不通过(下线)',
      AbnormalShtdown: ' 组件异常退出',
      AbnormalExited: '组件异常退出',
      AbnormalRecovery: '恢复正常',
      '': '-',
      'create-service': '创建组件',
      'batch-build-service': '批量构建组件',
      'batch-start-service': '批量启动组件',
      'batch-stop-service': '批量停止组件',
      'batch-upgrade-service': '批量升级组件',
      'build-service': '构建组件',
      build: '构建组件',
      upgrade: '滚动升级组件',
      'start-service': '启动组件',
      start: '启动组件',
      'add-app-autoscaler-rule': '添加自动伸缩规则',
      'update-app-autoscaler-rule': '更新自动伸缩规则',
      'stop-service': '停止组件',
      stop: '停止组件',
      'restart-service': '重启组件',
      restart: '重启组件',
      'vertical-service': '垂直扩展组件',
      vertical: '垂直扩展组件',
      'horizontal-service': '水平扩展组件',
      horizontal: '水平扩展组件',
      'set-language': '设置组件语言',
      'delete-service': '删除组件',
      'upgrade-service': '升级组件',
      'delete-buildversion': '删除构建版本',
      'share-service': '分享组件',
      'share-wb': '分享到内部市场',
      'share-ws': '分享到云端市场',
      'share-yb': '发布到市场',
      'share-ys': '发布到市场',
      updata: '更新组件',
      'add-service-dependency': '添加组件依赖',
      'delete-service-dependency': '删除组件依赖',
      'add-service-env': '添加组件环境变量',
      'update-service-env': '更新组件环境变量',
      'delete-service-env': '删除组件环境变量',
      'add-service-port': '添加组件端口',
      'update-service-port-old': '更新组件端口',
      'update-service-port': '更新组件端口',
      'delete-service-port': '删除组件端口',
      'handle-service-outerport': '修改组件对外端口',
      'handle-service-innerport': '修改组件对内端口',
      'change-service-lbport': '修改组件LB端口',
      'rollback-service': '回滚',
      'add-service-volume': '添加组件持久化存储',
      'update-service-volume': '更新组件持久化存储',
      'delete-service-volume': '删除组件持久化存储',
      'add-service-depvolume': '添加组件依赖存储',
      'delete-service-depvolume': '删除组件依赖存储',
      'add-service-probe': '添加组件探针',
      'update-service-probe': '更新组件探针',
      'delete-service-probe': '删除组件探针',
      'add-service-label': '添加组件标签',
      'update-service-label': '更新组件标签',
      'delete-service-label': '删除组件标签',
      'add-thirdpart-service': '添加第三方组件',
      'update-thirdpart-service': '更新第三方组件',
      'delete-thirdpart-service': '删除第三方组件',
      'update-service-gateway-rule': '更新组件网关规则',
      'app-restore-envs': '重新加载应用环境变量',
      'app-restore-ports': '重新加载应用端口',
      'app-restore-volumes': '重新加载应用存储',
      'app-restore-probe': '重新加载应用探针',
      'app-restore-deps': '重新加载应用依赖',
      'app-restore-depvols': '重新加载应用依赖存储',
      'app-restore-plugins': '重新加载应用插件',
    };
    return statusOptType[state] || state;
  },
  replaceUrlTeam(team) {
    let href = location.href;
    const reg = /team\/([^/]+)/;
    href = href.replace(reg, (string, g1) =>
      string.replace(new RegExp(g1), team)
    );
    return href;
  },
  replaceUrlRegion(region) {
    let href = location.href;
    const reg = /region\/([^/]+)/;
    href = href.replace(reg, (string, g1) =>
      string.replace(new RegExp(g1), region)
    );
    return href;
  },
  replaceUrlTeamAndTegion(team, region) {
    let href = location.href;
    const reg = /team\/([^/]+)\/region\/([^/]+)/;
    href = href.replace(reg, (string, g1, g2) =>
      string.replace(new RegExp(g1), team).replace(new RegExp(g2), region)
    );
    return href;
  },
  getSupportComponentTyps() {
    return [
      {
        type: 'state_singleton',
        name: this.getComponentType('state_singleton'),
        desc: '部署为Statefulset类型，一般用于DB类，消息中间件类，数据类组件 ',
      },
      {
        type: 'state_multiple',
        name: this.getComponentType('state_multiple'),
        desc: '可多实例运行的有状态组件',
      },
      {
        type: 'stateless_singleton',
        name: this.getComponentType('stateless_singleton'),
        desc: '部署为Deployment, 一般用于Web类，API类等组件，不可扩展实例数',
      },
      {
        type: 'stateless_multiple',
        name: this.getComponentType('stateless_multiple'),
        desc: '可多实例运行的无状态组件',
      },
    ];
  },
  getComponentType(componentType) {
    switch (componentType) {
      case 'state_singleton':
        return '有状态单实例';
      case 'state_multiple':
        return '有状态多实例';
      case 'stateless_singleton':
        return '无状态单实例';
      case 'stateless_multiple':
        return '无状态多实例';
    }
  },
  isStateComponent(componentType) {
    if (
      componentType == 'state_singleton' ||
      componentType == 'state_multiple'
    ) {
      return true;
    }
    return false;
  },
  isSingletonComponent(componentType) {
    if (
      componentType == 'state_singleton' ||
      componentType == 'stateless_singleton'
    ) {
      return true;
    }
    return false;
  },
};

export default global;
